﻿using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SimpleTicketBooking.Controllers.Base;
using SimpleTicketBooking.Models;
using SimpleTicketBooking.Models.Query;
using SimpleTicketBooking.Utils.Ext;
using System.ComponentModel;

namespace SimpleTicketBooking.Controllers
{
    /// <summary>
    /// Event Resources
    /// </summary>
    [ApiVersion((double)ApiVersions.V1)]
    [ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
    [ApiController]
    [Route("api/[controller]/v{version:apiVersion}/[action]")]
    //[Authorize(Roles ="admin,user")]
    public class EventController : APIControllerBase
    {
        private readonly ILogger<EventController> _logger;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="_logger"></param>
        public EventController(ILogger<EventController> _logger)
        {
            this._logger = _logger;
        }

        /// <summary>
        /// Get User by Id
        /// </summary>
        /// <param name="Id">User Id</param>
        /// <returns></returns>
        [HttpGet]
        [Description("Get event details by Event Id")]
        public Event GetById(int Id)
        {
            // TODO: validate input parameters

            return new Event() { Id = 1, Name= "Michael Jackson", Description="Pop event", Venue="U.S.", IsAvailable=true, Price=100};
        }

        /// <summary>
        /// Get all available events
        /// </summary>
        /// <param name="pageQuery"></param>
        /// <returns></returns>
        [HttpGet(Name = "events")]
        public IEnumerable<Event> GetAll([FromQuery] PageQuery pageQuery)
        {
            return new List<Event>() { };
        }

        /// <summary>
        /// update event info
        /// </summary>
        /// <param name="event"></param>
        /// <returns></returns>
        [HttpPut]
        public bool Update(Event eventModel)
        {
            return true;
        }

        /// <summary>
        /// Add new Event
        /// </summary>
        /// <param name="eventModel"></param>
        /// <returns></returns>
        [HttpPost]
        public bool Add([FromBody] Event eventModel)
        {
            return true;
        }

        /// <summary>
        /// Delete by Id
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpDelete]
        public bool Delete(int Id)
        {
            // TODO: validate input parameters

            // perform logical deletion
            return true; 
        }
    }
}
